package cn.zswltech.gruul.auth;

import cn.zswltech.gruul.common.constant.SystemConstant;
import cn.zswltech.gruul.common.result.MSG;
import cn.zswltech.gruul.exception.AuthException;
import cn.zswltech.gruul.web.api.util.RequestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Jim
 * @version 1.0.0
 * @descripition: 权限管理器路由
 * @date 2024/2/2 10:55
 */
@Component
public class AuthCheckerDispatcher {

    @Autowired
    private ThirdApplicationAuthChecker thirdApplicationAuthChecker;

    @Autowired
    private WLApplicationChecker wlApplicationChecker;

    public ApplicationAuthChecker routeAuthChecker(){
        String systemCode = RequestUtil.getSystemCode();
        if (null == systemCode){
            return thirdApplicationAuthChecker;
        }
        if (SystemConstant.APP_ZHFK.equals(systemCode)){
            return wlApplicationChecker;
        }else if (SystemConstant.APP_PASJ.equals(systemCode)){
            return thirdApplicationAuthChecker;
        }
        throw new AuthException(MSG.req_error_unknown_system_code);
        
    }

}
